//
//  NSMutableDictionary+CrashIntercept.m
//  Pods
//
//  Created by 余思豪 on 2022/9/22.
//

#import <Foundation/Foundation.h>
#import <objc/message.h>

@implementation NSMutableDictionary (CrashIntercept)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = NSClassFromString(@"__NSDictionaryM");
        // set
        Method method_1 = class_getInstanceMethod(class, @selector(setObject:forKey:));
        Method method_2 = class_getInstanceMethod(class, @selector(YSH_setObject:forKey:));
        method_exchangeImplementations(method_1, method_2);
    });
}

- (void)YSH_setObject:(id)anObject forKey:(id<NSCopying>)aKey {
    if (!anObject) return;
    [self YSH_setObject:anObject forKey:aKey];
}

@end
